package com.bwie.system.controller;

import com.bwie.common.domain.Shop;
import com.bwie.common.result.Result;
import com.bwie.system.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author：贾维斯
 * @Description: 描述
 * @name：ShopController
 * @Date：2024/11/4 9:58
 */
@RestController
public class ShopController {
    @Autowired
    private ShopService shopService;

    @PostMapping("/findShop")
    public Result<List<Shop>> findShop() {
        List<Shop> list = shopService.findShop();
        return Result.success(list);
    }

    @PostMapping("/addShop")
    public void addShop(@RequestBody Shop shop) {
        shopService.addShop(shop);
    }

    @PostMapping("/delShop/{id}")
    public void delShop(@PathVariable Integer id) {
        shopService.delShop(id);
    }

    @PostMapping("/updShop")
    public void updShop(@RequestBody Shop shop) {
        shopService.updShop(shop);
    }

    @PostMapping("/findById/{id}")
    public Result<Shop> findById(@PathVariable Integer id) {
       Shop shop = shopService.findById(id);
       return Result.success(shop);
    }
}
